////
////  ZMNetTool.swift
////  SwiiftProject
////
////  Created by Apple on 2019/5/13.
////  Copyright © 2019 lazyloading. All rights reserved.
////
//
//import Foundation
//import Alamofire
//
//
//
//enum ZMRequestUrl  : String{
//    case login = "/giftList.ios";
//}
//
//
//class ZMNetWork {
//    let baseUrl = "http://qf.56.com/pay/v4";
//    static let shared = ZMNetWork()
//
//}
//
////MARK: 🐷 扩展 🐷
//extension ZMNetWork{
//
//    //MARK: 🐶 业务请求 🐶
////    func postRequest<T>(_ url : String , _ param : Dictionary<String,Any>,
////                        success:@escaping(BaseResponse<T>) -> Void,
////                        failure:@escaping(Any) -> Void) -> Void {
////
////        self.requestAPI(self.baseUrl + url, param,  .post, success: { (response) in
////
////            let responseModel = BaseResponse<T>.deserialize(from: response.rawString());
////            success(responseModel!);
////
////        }, failure: failure);
////    }
////    func getRequest<T>(_ url : String , _ param : Dictionary<String,Any>,
////                       success:@escaping(BaseResponse<T>) -> Void,
////                       failure:@escaping(Any) -> Void) -> Void {
////
////        self.requestAPI(self.baseUrl + url, param,  .get, success: { (response) in
////
////            let responseModel = BaseResponse<T>.deserialize(from: response.rawString());
////            success(responseModel!);
////
////        }, failure: failure);
////    }
//    //MARK: 🐶 基础请求 🐶
//    /// 网络请求方法
//    ///
//    /// - Parameters:
//    ///   - url: url
//    ///   - param: 参数
//    ///   - method: 方法类型
//    ///   - success: 成功回调
//    ///   - failure: 失败回调
////    func requestAPI(_ url : String,_ param : Dictionary<String,Any>,_ method : HTTPMethod,
////                    success:@escaping(Any) -> Void,
////                    failure:@escaping(Error) -> Void) -> Void {
////
////        let headers = ["Content-Type": "application/json"]
////        Alamofire.request(url, method: method, parameters: param, encoding: JSONEncoding.default, headers: headers).responseJSON { (response) in
////            switch response.result{
////            case .success(let value):
////                let json = JSON.init(value);
////
////                success(json);
////                break
////
////            case .failure(let error):
////                failure(error);
////                break
////            }
////        }
////    }
//
//
//    /// 上传文件
//    ///
//    /// - Parameters:
//    ///   - url: url
//    ///   - params: 参数
//    ///   - files: 上传文件组
//    ///   - success: 成功回调
//    ///   - failure: 失败回调
//    func upload<T>(_ url : String ,_ params : [String : Any],_ files : Array<FileModel>,
//                   success : @escaping(BaseResponse<T>?) -> Void,
//                   failure : @escaping(Error) -> Void) ->  Void{
//
//        Alamofire.upload(multipartFormData: { (multipartFormData) in
//            for model in files{
//                multipartFormData.append(model.data, withName: model.name, fileName: model.fileName, mimeType: model.mimeType);
//            }
//        }, to: url) { (encodingResult) in
//
//            switch encodingResult {
//            case .success(let upload, _, _):
//                upload.responseJSON { response in
//                    if let data = response.data {
//                        let json =  JSON.init(data)
//                        let responseModel = BaseResponse<T>.deserialize(from: json.rawString());
//                        success(responseModel);
//                    } else {
//                        let responseModel = BaseResponse<T>();
//                        responseModel.msg = "解析失败"
//                        success(responseModel);
//                    }
//                }
//                break;
//            case .failure(let error):
//                failure(error);
//                break;
//            }
//        }
//    }
//
//}
//
//class FileModel {
//
//    var fileName : String!;
//    var data : Data!;
//    var name : String!;
//    var mimeType : String!;
//
//    required init() {}
//}
